package cn.lzd.mr.PracticeGroup;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * Created by lzd on 2018/8/3.
 */
public class PracticeCustomGroup2 extends WritableComparator {

    public PracticeCustomGroup2() {
        super(PBean.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        System.out.println("====================================reduce分组开始-结束====================================");

        PBean bean1 = (PBean) a;
        PBean bean2 = (PBean) b;
        String key1 = bean1.getName();
        String key2 = bean2.getName();

        if (key1.indexOf(key2) != -1) {
            return 0;
        } else if (key2.indexOf(key1) != -1) {
            return 0;
        }
        return 1;
    }
}
